﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DataMappers;
using ExaminationTT.Model;

namespace ConcreteMappersAndObjects.DomainObjects
{
    public class SClass : DomainObject<int, SClass> , IClass
    {
        private string _name;
        protected override SClass Self()
        {
            return this;
        }

        #region IClass Members

        private IValueHolder<int, Regime> _regime;
        private IValueHolder<int, Course> _course;
        private IEnumerable<TeacherClassCUnit> _tccu;

        public SClass() : base()
        {
            _regime = new ConcreteValueHolder<int, Regime>();
            _course = new ConcreteValueHolder<int, Course>();
        }
        public SClass(int id, string name, IValueHolder<int, Regime> regime, 
            IValueHolder<int, Course> course, IEnumerable<TeacherClassCUnit> tccu) : base(id)
        {
            _name = name;
            _regime = regime;
            _course = course;
            _tccu = tccu;

        }


        public string Name
        {
            get { return _name; }
            set { _name = value; MarkDirty(); }
        }

        public Regime Regime
        {
            get { if (_regime == null) { return null; } return _regime.Get(); }
            set { _regime.Set(value); }
            
        }

        public Course Course
        {
            get { if (_course == null) return null; return _course.Get(); }
            set { _course.Set(value); }
           
        }


        public IEnumerable<TeacherClassCUnit> TeachersCunits
        {
            get { return _tccu.ToList();}
            set { _tccu = value; }          
        }

        #endregion

        #region IClass Members

        string IClass.Name
        {
            get { return _name; }
        }

        IRegime IClass.Regime
        {
            get { return _regime.Get(); }
        }

        ICourse IClass.Course
        {
            get { return _course.Get(); }
        }

        IEnumerable<ITeacherClassCUnit> IClass.TeachersCunits
        {
            get { return _tccu.ToList(); }
        }

        #endregion
    }
}
